/*
 * CLivingObject.cpp
 *
 *  Created on: 26.04.2009
 *      Author: markus
 */

#include "CLivingObject.h"

LivingObject::LivingObject() : BaseObject()
{
        m_moveConst = 1.0;
        m_rotConst = 0.1;
	m_sceneNode = NULL;
//	m_v3Direction = Ogre::Vector3::ZERO;
        m_translationOrder = Ogre::Vector3::ZERO;
	m_eInvertMouse = INV_FALSE;
        m_sprintConst = 1.0;

        m_Type = TYPE_NONE;
        m_controlable = false;
}

LivingObject::~LivingObject()
{

}

void LivingObject::setMoveConst(float fMoveConst)
{
        m_moveConst = Ogre::Real(fMoveConst);
}

float LivingObject::getRotationConst()
{
        return (float)m_rotConst;
}

void LivingObject::setRotationConst(float fRotConst)
{
        m_rotConst = Ogre::Real(fRotConst);

}

void LivingObject::moveX(float fX)
{
        m_translationOrder.x += fX * (float)(m_moveConst);
}

void LivingObject::moveY(float fY)
{
        m_translationOrder.y += fY * (float)(m_moveConst);
}

void LivingObject::moveZ(float fZ)
{
        m_translationOrder.z += fZ * (float)(m_moveConst);
}

void LivingObject::rotate(float fX, float fY, float fZ)
{
        m_sceneNode->yaw(Ogre::Degree(-fX * (float)m_rotConst), Ogre::Node::TS_WORLD);
        m_sceneNode->pitch(Ogre::Degree(m_eInvertMouse * fY * (float)m_rotConst), Ogre::Node::TS_LOCAL);
}

float LivingObject::getMoveConst()
{
        return (float)m_moveConst;
}

void LivingObject::setSprintMove(bool bSprintMove)
{
	if(bSprintMove)
	{
                m_sprintConst = 3.0;
	}
	else
	{
                m_sprintConst = 1.0;
	}

//	if(bSprintMove)
//	{
//		m_v3Position *= m_realSprintConst;
//	}
//	else
//	{
//		m_v3Position /= m_realSprintConst;
//	}

	return;
}

float LivingObject::getSprintMove()
{
        return (float)m_sprintConst;
}

void LivingObject::translate(double scalingFactor)
{
    Ogre::Vector3 translation = m_sprintConst * m_translationOrder * scalingFactor;

    m_Transform.setOrigin(btVector3(m_Transform.getOrigin().getX() + translation.x,
                                 m_Transform.getOrigin().getY() + translation.y,
                                 m_Transform.getOrigin().getZ() + translation.z
                                 ));

    m_sceneNode->translate(translation, Ogre::Node::TS_LOCAL );
}
